﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using Wjtour.Common;
using Hjp.FrameWork.Common;

namespace Wjtour.Web.Front
{
    public partial class travelguideview : BasePage
    {
        private Wjtour.BLL.article_bll _bll = new BLL.article_bll();
        protected Wjtour.Domain.article data = new Domain.article();
        protected int id = 0;
        protected LinkButton zan;

        protected void Page_Load(object sender, EventArgs e)
        {
            id = Utils.StrToInt(Request["id"], 0);
            zan.Click += zan_Click;
            if (id > 0)
            {
                data = _bll.Load(id);
                if (!IsPostBack)
                {
                    data.hits += 1;
                    _bll.Save(data);
                }
            }
        }

        void zan_Click(object sender, EventArgs e)
        {
            data.zan += 1;
            _bll.Save(data);
            string cookiename = string.Format("{0}_{1}_{2}", Utils.GetRealIP(), "travelguideview", id);
            HttpCookie cookie = new HttpCookie(cookiename, "true");
            cookie.Expires = DateTime.Now.AddDays(1.0);
            Response.Cookies.Add(cookie);
        }
    }
}
